package com.mychat.enums;

import com.mychat.utils.StringUtils;

public enum JoinTypeEnum {
    JOIN(0, "直接加入"),
    APPLY(1, "需要审核");

    private Integer type;
    private String desc;

    JoinTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public static JoinTypeEnum getByName(String name) {
        if(StringUtils.isEmpty(name)) {
            return null;
        }
        return JoinTypeEnum.valueOf(name.toUpperCase());
    }

    public static JoinTypeEnum getByType(Integer type) {
        for(JoinTypeEnum joinTypeEnum : JoinTypeEnum.values()) {
            if(joinTypeEnum.getType().equals(type)) {
                return joinTypeEnum;
            }
        }
        return null;
    }
}
